package com.ujs.edu.medicine.util;

import com.ujs.edu.medicine.dao.YunjiayiUserMapper;
import com.ujs.edu.medicine.dataobject.YunjiayiUser;
import org.junit.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;

import java.text.DateFormat;
import java.text.ParseException;
import java.text.ParsePosition;
import java.text.SimpleDateFormat;
import java.util.Date;

/**
 * @Author:
 * @Date: Created in 19:20 2020/9/8
 * Description: 时间格式转换
 * Modified By:
 */
public class DateFormate {

    @Autowired
    private YunjiayiUserMapper yunjiayiUserMapper;

    private  static String date="2020-09-24 20:02:58";

    /*将长时间转换为字符串yyyy-MM-dd HH:mm:ss*/
    public static String dataToString(String date) throws ParseException {

        SimpleDateFormat format=new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");

        return format.parse(date).toString();
    }




    @Test
    public void maintest() throws ParseException {
        YunjiayiUser user=yunjiayiUserMapper.selectByPrimaryKey(1);

//        System.out.println(new Date());
//        System.out.println(dataToString(user.getCreateTime().toString()));
    }

}
